package com.enjoyor.soa.traffic.rest.efoms.controller;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.alibaba.fastjson.JSONObject;
import com.enjoyor.soa.traffic.api.dto.efoms.CheckDeviceInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.CheckRecodeInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.DeviceDetailInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.FacilitySimpleInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.RepairsInfoDto;
import com.enjoyor.soa.traffic.api.dto.efoms.WorkordersInfoDto;
import com.enjoyor.soa.traffic.frame.annotation.Auth;
import com.enjoyor.soa.traffic.frame.support.file.IFilesTool;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.ICheckDeviceInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.ICheckRecordInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.ICheckReportConsumService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IDeviceDetailInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IFacilitySimpleInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IRepairsInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.dubbo.IWorkordersInfoConsumeService;
import com.enjoyor.soa.traffic.rest.efoms.enums.EnumDicPublicRest;
import com.enjoyor.soa.traffic.rest.efoms.helper.CustomHSSFCell;
import com.enjoyor.soa.traffic.rest.efoms.helper.ExcelExportTools;
import com.enjoyor.soa.traffic.util.helper.TimeHelper;
import com.enjoyor.soa.traffic.util.pojo.Page;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;

@Auth
@RestController
@RequestMapping({ "/export" })
@Api("ExcelExportController相关api")
@CrossOrigin
public class ExcelExportController {
	@Autowired
	private IRepairsInfoConsumeService repairsInfoConsumeService;

	@Autowired
	private IWorkordersInfoConsumeService workordersInfoConsumeService;

	@Autowired
	private IDeviceDetailInfoConsumeService deviceDetailConsumeService;

	@Autowired
	private IFacilitySimpleInfoConsumeService facilitySimpleConsumeService;

	@Autowired
	private ICheckRecordInfoConsumeService checkRecordInfoConsumeService;

	@Autowired
	private ICheckDeviceInfoConsumeService checkDeviceInfoConsumeService;
	
	@Autowired
	private ICheckReportConsumService iCheckReportConsumService;

	@Autowired
	private IFilesTool filesTool;

	@Value("${file.handle.file-addr}")
	private String RestRoot;

	@Value("${file.handle.file-dir}")
	private String FileRoot;

	@GetMapping(value = { "/exportRepairs" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response = RepairsInfoDto.class, code = 0, message = "")
	@ApiOperation("报修单信息导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "repairsId", value = "报修单ID", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repStatusCode", value = "报修状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaCode", value = "所属区域编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "key", value = "设备名称或设备编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repDeptIds", value = "部门ID", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "press", value = "今日催办", paramType = "query", dataType = "String") })
	public Map<String, Object> exportRepairs(
			@RequestParam(defaultValue = "", value = "repairsId", required = false) String repairsId,
			@RequestParam(defaultValue = "", value = "repStatusCode", required = false) String repStatusCode,
			@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
			@RequestParam(defaultValue = "", value = "devAreaCode", required = false) String devAreaCode,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "repDeptIds", required = false) String repDeptIds,
			@RequestParam(defaultValue = "", value = "startTime", required = false) String startTime,
			@RequestParam(defaultValue = "", value = "endTime", required = false) String endTime,
			@RequestParam(defaultValue = "", value = "press", required = false) String press, Page page,
			HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		try {
			@SuppressWarnings("unchecked")
			Page repairsPage = (Page) repairsInfoConsumeService
					.selectPage(page, null, null, null, null, null, null, null, null, null).getResultList();
			List<RepairsInfoDto> listObject = JSONObject.parseArray(JSONObject.toJSONString(repairsPage.getResult()),
					RepairsInfoDto.class);
			// 导出
			List<RepairsInfoDto> listRepairsDto = new ArrayList<>();
			if (listObject.size() > 0) {
				for (int i = 0; i < listObject.size(); i++) {
					RepairsInfoDto repairsInfoDto = listObject.get(i);
					listRepairsDto.add(repairsInfoDto);
				}
			}
			CustomHSSFCell[] headers = new CustomHSSFCell[8];
			ExcelExportTools et = new ExcelExportTools();
			headers[0] = new CustomHSSFCell("设备名称", 0, 0, 30, "devName");
			headers[1] = new CustomHSSFCell("设备类型", 1, 0, 30, "devTypeName");
			headers[2] = new CustomHSSFCell("所属辖区", 2, 0, 30, "devAreaName");
			headers[3] = new CustomHSSFCell("故障描述", 3, 0, 30, "failureDescrible");
			headers[4] = new CustomHSSFCell("报修单位", 4, 0, 30, "repDeptName");
			headers[5] = new CustomHSSFCell("报修人", 5, 0, 30, "repPersonName");
			headers[6] = new CustomHSSFCell("报修时间", 6, 0, 30, "repDate");
			headers[7] = new CustomHSSFCell("报修状态", 7, 0, 30, "repStatusName");
			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "报修单信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listRepairsDto, headers, filePath, "报修单信息表", "yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}

	@GetMapping(value = { "/exportWorkorders" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiResponse(response = RepairsInfoDto.class, code = 0, message = "")
	@ApiOperation("维修工单信息导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "workordersId", value = "维修工单编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repStartDate", value = "报修开始时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repEndDate", value = "报修结束时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devCategoryCode", value = "设备种类编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "key", value = "关键字（设备编号或设备名称）", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaCode", value = "设备所属区域", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devDeptId", value = "设备所属部门", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "failureTypeCode", value = "故障类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "failureDescrible", value = "故障描述", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repSourceCode", value = "报修来源编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "workordersStatusCode", value = "工单状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "orderSeq", value = "排序列名(创建时间CREATE_DATE,截止时间DEADLINE_TIME,结束时间FINISH_TIME)", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "orderMode", value = "排序方式(升序asc,降序desc)", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "lableClick", value = "标签勾选(催办press、延期postpone、逾期overtime、进度反馈fackback、驳回isreject)", paramType = "query", dataType = "String") })
	public Map<String, Object> exportWorkorders(
			@RequestParam(defaultValue = "", value = "workordersId", required = false) String workordersId,
			@RequestParam(defaultValue = "", value = "repStartDate", required = false) String repStartDate,
			@RequestParam(defaultValue = "", value = "repEndDate", required = false) String repEndDate,
			@RequestParam(defaultValue = "", value = "devCategoryCode", required = false) String devCategoryCode,
			@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
			@RequestParam(defaultValue = "", value = "devId", required = false) String devId,
			@RequestParam(defaultValue = "", value = "devName", required = false) String devName,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "devAreaCode", required = false) String devAreaCode,
			@RequestParam(defaultValue = "", value = "devDeptId", required = false) String devDeptId,
			@RequestParam(defaultValue = "", value = "failureTypeCode", required = false) String failureTypeCode,
			@RequestParam(defaultValue = "", value = "failureDescrible", required = false) String failureDescrible,
			@RequestParam(defaultValue = "", value = "repSourceCode", required = false) String repSourceCode,
			@RequestParam(defaultValue = "", value = "workordersStatusCode", required = false) String workordersStatusCode,
			@RequestParam(defaultValue = "", value = "orderSeq", required = false) String orderSeq,
			@RequestParam(defaultValue = "", value = "orderMode", required = false) String orderMode,
			@RequestParam(defaultValue = "", value = "lableClick", required = false) String lableClick, Page page,
			HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		try {
			@SuppressWarnings("unchecked")
			Page workordersPage = (Page) workordersInfoConsumeService
					.selectWorkordersInfoPage(page, workordersId, repStartDate, repEndDate, devCategoryCode,
							devTypeCode, devId, devName, key, devAreaCode, devDeptId, failureTypeCode, failureDescrible,
							repSourceCode, workordersStatusCode, orderSeq, orderMode, lableClick, null)
					.getResultList();
			List<WorkordersInfoDto> listObject = JSONObject
					.parseArray(JSONObject.toJSONString(workordersPage.getResult()), WorkordersInfoDto.class);
			// 导出
			List<WorkordersInfoDto> listWorkordersInfoDto = new ArrayList<>();
			if (listObject.size() > 0) {
				for (int i = 0; i < listObject.size(); i++) {
					WorkordersInfoDto workordersInfoDto = listObject.get(i);
					listWorkordersInfoDto.add(workordersInfoDto);
				}
			}
			CustomHSSFCell[] headers = new CustomHSSFCell[8];
			ExcelExportTools et = new ExcelExportTools();
			headers[0] = new CustomHSSFCell("设备名称", 0, 0, 30, "devName");
			headers[1] = new CustomHSSFCell("设备类型", 1, 0, 30, "devTypeName");
			headers[2] = new CustomHSSFCell("所属辖区", 2, 0, 30, "devAreaName");
			headers[3] = new CustomHSSFCell("故障描述", 3, 0, 30, "failureDescrible");
			headers[4] = new CustomHSSFCell("报修单位", 4, 0, 30, "repDeptName");
			headers[5] = new CustomHSSFCell("报修人", 5, 0, 30, "repPersonName");
			headers[6] = new CustomHSSFCell("报修时间", 6, 0, 30, "repDate");
			headers[7] = new CustomHSSFCell("报修状态", 7, 0, 30, "workordersStatusName");
			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "工单信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listWorkordersInfoDto, headers, filePath, "工单信息表", "yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}

	// 设备导出功能；
	@GetMapping(value = { "/exportDeviceInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("设备信息导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "DevId", value = "设备编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "key", value = "关键字（设备编号或设备名称）", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devStatusCode", value = "设备状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaCode", value = "管辖区域编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devDeptId", value = "管理部门编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devFactory", value = "生成厂家", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "oppmDept", value = "维修单位", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repStatusCode", value = "报修状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "buildBeginDate", value = "建设开始日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "buildEndDate", value = "建设结束日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "shelfBeginDate", value = "质保到期开始日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "shelfEndDate", value = "质保到期结束日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "oppmBeginDate", value = "下次维护开始日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "oppmEndDate", value = "下次维护结束日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "deviceStatus", value = "设备使用状态编号", paramType = "query", dataType = "String") })
	public Map<String, Object> exportDeviceInfo(
			@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
			@RequestParam(defaultValue = "", value = "DevId", required = false) String DevId,
			@RequestParam(defaultValue = "", value = "devName", required = false) String devName,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "devStatusCode", required = false) String devStatusCode,
			@RequestParam(defaultValue = "", value = "devAreaCode", required = false) String devAreaCode,
			@RequestParam(defaultValue = "", value = "devDeptId", required = false) String devDeptId,
			@RequestParam(defaultValue = "", value = "devFactory", required = false) String devFactory,
			@RequestParam(defaultValue = "", value = "oppmDept", required = false) String oppmDept,
			@RequestParam(defaultValue = "", value = "repStatusCode", required = false) String repStatusCode,
			@RequestParam(defaultValue = "", value = "buildBeginDate", required = false) String buildBeginDate,
			@RequestParam(defaultValue = "", value = "buildEndDate", required = false) String buildEndDate,
			@RequestParam(defaultValue = "", value = "shelfBeginDate", required = false) String shelfBeginDate,
			@RequestParam(defaultValue = "", value = "shelfEndDate", required = false) String shelfEndDate,
			@RequestParam(defaultValue = "", value = "oppmBeginDate", required = false) String oppmBeginDate,
			@RequestParam(defaultValue = "", value = "oppmEndDate", required = false) String oppmEndDate,
			@RequestParam(defaultValue = "", value = "deviceStatus", required = false) String deviceStatus, Page page,
			HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		try {
			@SuppressWarnings("unchecked")
			Page deviceDetailInfoPage = (Page) deviceDetailConsumeService
					.selectAssetDevicePage(devTypeCode, DevId, devName, key, devStatusCode, devAreaCode, devDeptId,
							devFactory, oppmDept, repStatusCode, buildBeginDate, buildEndDate, shelfBeginDate,
							shelfEndDate, oppmBeginDate, oppmEndDate, deviceStatus, page)
					.getResultList();
			List<DeviceDetailInfoDto> listObject = JSONObject
					.parseArray(JSONObject.toJSONString(deviceDetailInfoPage.getResult()), DeviceDetailInfoDto.class);
			// 导出
			List<DeviceDetailInfoDto> listDeviceDetailInfoDto = new ArrayList<>();
			if (listObject.size() > 0) {
				for (int i = 0; i < listObject.size(); i++) {
					DeviceDetailInfoDto deviceDetailInfoDto = listObject.get(i);
					listDeviceDetailInfoDto.add(deviceDetailInfoDto);
				}
			}
			CustomHSSFCell[] headers = new CustomHSSFCell[9];
			ExcelExportTools et = new ExcelExportTools();
			headers[0] = new CustomHSSFCell("设备编号", 0, 0, 30, "devId");
			headers[1] = new CustomHSSFCell("设备名称", 1, 0, 30, "devName");
			headers[2] = new CustomHSSFCell("所属辖区", 2, 0, 30, "devAreaName");
			headers[3] = new CustomHSSFCell("生产厂家", 3, 0, 30, "devFactory");
			headers[4] = new CustomHSSFCell("设备建设时间", 4, 0, 30, "devBuildDate");
			headers[5] = new CustomHSSFCell("维护单位", 5, 0, 30, "oppmDept");
			headers[6] = new CustomHSSFCell("IP地址", 6, 0, 30, "devIp");
			headers[7] = new CustomHSSFCell("设备状态", 7, 0, 30, "devStatusName");
			headers[8] = new CustomHSSFCell("使用状态", 8, 0, 30, "repStatusName");
			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "设备信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listDeviceDetailInfoDto, headers, filePath, "设备信息表",
					"yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}

	// 设施导出功能；
	@GetMapping(value = { "/exportfacilityInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("设施信息导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "facilityTypeCode", value = "设施类型编号", paramType = "query", required = true, dataType = "String"),
			@ApiImplicitParam(name = "facilityId", value = "设施编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "facilityName", value = "设施名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "key", value = "关键字（设施编号或设施名称）", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devStatusCode", value = "设施状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "regionId", value = "管辖区域编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "signsType", value = "设施子类编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "signsCode", value = "设施小类编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "roadId", value = "道路编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "blockId", value = "路段编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "crossId", value = "路口编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "manageDept", value = "管理部门编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "manufact", value = "生产厂家", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repStatusCode", value = "报修状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "buildBeginDate", value = "建设开始日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "buildEndDate", value = "建设结束日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "updateBeginTime", value = "更新开始日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "updateEndTime", value = "更新结束日期", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "deviceStatus", value = "使用状态编号", paramType = "query", dataType = "String") })
	public Map<String, Object> exportfacilityInfo(
			@RequestParam(defaultValue = "", value = "facilityTypeCode", required = true) String facilityTypeCode,
			@RequestParam(defaultValue = "", value = "facilityId", required = false) String facilityId,
			@RequestParam(defaultValue = "", value = "facilityName", required = false) String facilityName,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "devStatusCode", required = false) String devStatusCode,
			@RequestParam(defaultValue = "", value = "regionId", required = false) String regionId,
			@RequestParam(defaultValue = "", value = "signsType", required = false) String signsType,
			@RequestParam(defaultValue = "", value = "signsCode", required = false) String signsCode,
			@RequestParam(defaultValue = "", value = "roadId", required = false) String roadId,
			@RequestParam(defaultValue = "", value = "blockId", required = false) String blockId,
			@RequestParam(defaultValue = "", value = "crossId", required = false) String crossId,
			@RequestParam(defaultValue = "", value = "manageDept", required = false) String manageDept,
			@RequestParam(defaultValue = "", value = "manufact", required = false) String manufact,
			@RequestParam(defaultValue = "", value = "repStatusCode", required = false) String repStatusCode,
			@RequestParam(defaultValue = "", value = "buildBeginDate", required = false) String buildBeginDate,
			@RequestParam(defaultValue = "", value = "buildEndDate", required = false) String buildEndDate,
			@RequestParam(defaultValue = "", value = "updateBeginTime", required = false) String updateBeginTime,
			@RequestParam(defaultValue = "", value = "updateEndTime", required = false) String updateEndTime,
			@RequestParam(defaultValue = "", value = "deviceStatus", required = false) String deviceStatus, Page page,
			HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		try {
			@SuppressWarnings("unchecked")
			Page FacilitySimpleInfoPage = (Page) facilitySimpleConsumeService.selectFacilitySimpleInfoPage(
					facilityTypeCode, facilityId, facilityName, key, devStatusCode, regionId, signsType, signsCode,
					roadId, blockId, crossId, manageDept, manufact, repStatusCode, buildBeginDate, buildEndDate,
					updateBeginTime, updateEndTime, deviceStatus, page).getResultList();
			List<FacilitySimpleInfoDto> listObject = JSONObject.parseArray(
					JSONObject.toJSONString(FacilitySimpleInfoPage.getResult()), FacilitySimpleInfoDto.class);
			// 导出
			List<FacilitySimpleInfoDto> listFacilitySimpleInfoDto = new ArrayList<>();
			if (listObject.size() > 0) {
				for (int i = 0; i < listObject.size(); i++) {
					FacilitySimpleInfoDto facilitySimpleInfoDto = listObject.get(i);
					listFacilitySimpleInfoDto.add(facilitySimpleInfoDto);
				}
			}
			CustomHSSFCell[] headers = new CustomHSSFCell[9];
			ExcelExportTools et = new ExcelExportTools();
			headers[0] = new CustomHSSFCell("设施编号", 0, 0, 30, "facilityId");
			headers[1] = new CustomHSSFCell("设施名称", 1, 0, 30, "facilityName");
			headers[2] = new CustomHSSFCell("设施子类型", 2, 0, 30, "signsTypeName");
			headers[3] = new CustomHSSFCell("所属道路", 3, 0, 30, "roadName");
			headers[4] = new CustomHSSFCell("所属辖区", 4, 0, 30, "regionName");
			headers[5] = new CustomHSSFCell("建设日期", 5, 0, 30, "buildDate");
			headers[6] = new CustomHSSFCell("维护单位", 6, 0, 30, "oppmDeptName");
			headers[7] = new CustomHSSFCell("设施状态", 7, 0, 30, "devStatusName");
			headers[8] = new CustomHSSFCell("使用状态", 8, 0, 30, "repStatusName");
			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "设施信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listFacilitySimpleInfoDto, headers, filePath, "设施信息表",
					"yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}

	// 巡检记录导出功能
	@GetMapping(value = { "/exportCheckRecordInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("巡检记录导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "CheckRecordInfoId", value = "巡检记录编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "checkPersonCode", value = "巡检人员编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaCode", value = "区域编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaName", value = "区域名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "checkPersonName", value = "巡检人名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devCategoryCode", value = "巡检人编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "checkResultCode", value = "巡检结果编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String")})
	public Map<String, Object> exportCheckRecordInfo(
			@RequestParam(defaultValue = "", value = "CheckRecordInfoId", required = false) String CheckRecordInfoId,
			@RequestParam(defaultValue = "", value = "devId", required = false) String devId,
			@RequestParam(defaultValue = "", value = "checkPersonCode", required = false) String checkPersonCode,
			@RequestParam(defaultValue = "", value = "startTime", required = false) String startTime,
			@RequestParam(defaultValue = "", value = "endTime", required = false) String endTime,
			@RequestParam(defaultValue = "", value = "devAreaCode", required = false) String devAreaCode,
			@RequestParam(defaultValue = "", value = "devAreaName", required = false) String devAreaName,
			@RequestParam(defaultValue = "", value = "checkPersonName", required = false) String checkPersonName,
			@RequestParam(defaultValue = "", value = "devCategoryCode", required = false) String devCategoryCode,
			@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
			@RequestParam(defaultValue = "", value = "checkResultCode", required = false) String checkResultCode,
			@RequestParam(defaultValue = "", value = "devName", required = false) String devName,
			Page page, HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		try {
			@SuppressWarnings("unchecked")
			Page CheckRecordInfoPage = (Page) checkRecordInfoConsumeService
					.getCheckRecordInfoPage(CheckRecordInfoId, devId, checkPersonCode, startTime, endTime, devAreaCode,
							devAreaName, checkPersonName, devCategoryCode, devTypeCode, checkResultCode,devName, page)
					.getResultList();
			List<CheckRecodeInfoDto> listObject = JSONObject
					.parseArray(JSONObject.toJSONString(CheckRecordInfoPage.getResult()), CheckRecodeInfoDto.class);
			// 导出
			List<CheckRecodeInfoDto> listCheckRecodeInfoDto = new ArrayList<>();
			if (listObject.size() > 0) {
				for (int i = 0; i < listObject.size(); i++) {
					CheckRecodeInfoDto checkRecodeInfoDto = listObject.get(i);
					listCheckRecodeInfoDto.add(checkRecodeInfoDto);
				}
			}
			CustomHSSFCell[] headers = new CustomHSSFCell[7];
			ExcelExportTools et = new ExcelExportTools();
			headers[0] = new CustomHSSFCell("巡检时间", 0, 0, 30, "checkTime");
			headers[1] = new CustomHSSFCell("设备名称", 1, 0, 30, "devTypeName");
			headers[2] = new CustomHSSFCell("设备类别", 2, 0, 30, "devCategoryName");
			headers[3] = new CustomHSSFCell("设备类型", 3, 0, 30, "devTypeName");
			headers[4] = new CustomHSSFCell("所属辖区", 4, 0, 30, "devAreaName");
			headers[5] = new CustomHSSFCell("负责人", 5, 0, 30, "checkPersonName");
			headers[6] = new CustomHSSFCell("巡检结果", 6, 0, 30, "checkResultName");
			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "巡检记录信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listCheckRecodeInfoDto, headers, filePath, "巡检记录信息表",
					"yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}

	// 运维管理导出
	@GetMapping(value = { "/exportWorkordersNoDispatch" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("运维管理信息导出")
	@ApiImplicitParams({
			@ApiImplicitParam(name = "workordersId", value = "维修工单编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repStartDate", value = "报修开始时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repEndDate", value = "报修结束时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devCategoryCode", value = "设备种类编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devId", value = "设备编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "key", value = "关键字（设备编号或设备名称）", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaCode", value = "设备所属区域", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devDeptId", value = "设备所属部门", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "failureTypeCode", value = "故障类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "failureDescrible", value = "故障描述", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repSourceCode", value = "报修来源编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "workordersStatusCode", value = "工单状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "orderSeq", value = "排序列名(创建时间CREATE_DATE,截止时间DEADLINE_TIME,结束时间FINISH_TIME)", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "orderMode", value = "排序方式(升序asc,降序desc)", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "lableClick", value = "标签勾选(催办press、延期postpone、逾期overtime、进度反馈fackback、驳回isreject)", paramType = "query", dataType = "String") })
	public Map<String, Object> exportWorkordersNoDispatch(
			@RequestParam(defaultValue = "", value = "workordersId", required = false) String workordersId,
			@RequestParam(defaultValue = "", value = "repStartDate", required = false) String repStartDate,
			@RequestParam(defaultValue = "", value = "repEndDate", required = false) String repEndDate,
			@RequestParam(defaultValue = "", value = "devCategoryCode", required = false) String devCategoryCode,
			@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
			@RequestParam(defaultValue = "", value = "devId", required = false) String devId,
			@RequestParam(defaultValue = "", value = "devName", required = false) String devName,
			@RequestParam(defaultValue = "", value = "key", required = false) String key,
			@RequestParam(defaultValue = "", value = "devAreaCode", required = false) String devAreaCode,
			@RequestParam(defaultValue = "", value = "devDeptId", required = false) String devDeptId,
			@RequestParam(defaultValue = "", value = "failureTypeCode", required = false) String failureTypeCode,
			@RequestParam(defaultValue = "", value = "failureDescrible", required = false) String failureDescrible,
			@RequestParam(defaultValue = "", value = "repSourceCode", required = false) String repSourceCode,
			@RequestParam(defaultValue = "", value = "workordersStatusCode", required = false) String workordersStatusCode,
			@RequestParam(defaultValue = "", value = "orderSeq", required = false) String orderSeq,
			@RequestParam(defaultValue = "", value = "orderMode", required = false) String orderMode,
			@RequestParam(defaultValue = "", value = "lableClick", required = false) String lableClick, Page page,
			HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		List<String> noStatusCodeList = new ArrayList<String>();
		noStatusCodeList.add(EnumDicPublicRest.ORD_WAITDISPATCH.getKey());
		noStatusCodeList.add(EnumDicPublicRest.ORD_ISDELETE.getKey());
		try {
			@SuppressWarnings("unchecked")
			Page workordersPage = (Page) workordersInfoConsumeService
					.selectWorkordersInfoPage(page, workordersId, repStartDate, repEndDate, devCategoryCode,
							devTypeCode, devId, devName, key, devAreaCode, devDeptId, failureTypeCode, failureDescrible,
							repSourceCode, workordersStatusCode, orderSeq, orderMode, lableClick, noStatusCodeList)
					.getResultList();
			List<WorkordersInfoDto> listObject = JSONObject
					.parseArray(JSONObject.toJSONString(workordersPage.getResult()), WorkordersInfoDto.class);
			// 导出
			List<WorkordersInfoDto> listworkordersInfoDto = new ArrayList<>();
			if (listObject.size() > 0) {
				for (int i = 0; i < listObject.size(); i++) {
					WorkordersInfoDto workordersInfoDto = listObject.get(i);
					if (workordersInfoDto.getIsOverdue() == true) {
						workordersInfoDto.setWorkordersStatusCode("已逾期");
					} else {
						workordersInfoDto.setWorkordersStatusCode("维修中");
					}
					listworkordersInfoDto.add(workordersInfoDto);
				}
			}
			CustomHSSFCell[] headers = new CustomHSSFCell[7];
			ExcelExportTools et = new ExcelExportTools();
			headers[0] = new CustomHSSFCell("设备名称", 0, 0, 30, "devName");
			headers[1] = new CustomHSSFCell("设备类型", 1, 0, 30, "devTypeName");
			headers[2] = new CustomHSSFCell("故障类型", 2, 0, 30, "failureTypeName");
			headers[3] = new CustomHSSFCell("工单创建时间", 3, 0, 30, "createDate");
			headers[4] = new CustomHSSFCell("维修期限", 4, 0, 30, "deadlineTime");
			headers[5] = new CustomHSSFCell("设备状态", 5, 0, 30, "workordersStatusCode");
			headers[6] = new CustomHSSFCell("工单状态", 6, 0, 30, "workordersStatusName");
			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "运维管理信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listworkordersInfoDto, headers, filePath, "运维管理信息表",
					"yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}

	// 巡检导出；
	@GetMapping(value = { "/exportChecckDeviceInfo" }, produces = { "application/json; charset=UTF-8" })
	@ResponseBody
	@ApiOperation("巡检导出")
	@ApiImplicitParams({ @ApiImplicitParam(name = "DevId", value = "设备编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devName", value = "设备名称", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "ledType", value = "诱导屏类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devStatusCode", value = "设备状态编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "isPingConnect", value = "网络是否联通", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "checkResultCode", value = "巡检结果编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devAreaCode", value = "区域编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "isDelayData", value = "是否延迟", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "isHightPackage", value = "是否高丢包", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "isHightResponse", value = "是否高响应", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "isHaveData", value = "是否有实时数据", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "devFactory", value = "设备厂家", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "searchFlag", value = "标签识别", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "beginLastPassTime", value = "最后上传开始时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "endLastPassTime", value = "最后上传结束时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "isPhotoSuccess", value = "照片是否上传成功", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "repStatusCode", value = "设备使用状态", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "project", value = "建设期数", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "company", value = "建设单位", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "picStatusFlag", value = "图片质量", paramType = "query", dataType = "String")})
	public Map<String, Object> exportChecckDeviceInfo(
			@RequestParam(defaultValue = "", value = "DevId", required = false) String DevId,
			@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
			@RequestParam(defaultValue = "", value = "devName", required = false) String devName,
			@RequestParam(defaultValue = "", value = "ledType", required = false) String ledType,
			@RequestParam(defaultValue = "", value = "devStatusCode", required = false) String devStatusCode,
			@RequestParam(defaultValue = "", value = "isPingConnect", required = false) String isPingConnect,
			@RequestParam(defaultValue = "", value = "checkResultCode", required = false) String checkResultCode,
			@RequestParam(defaultValue = "", value = "devAreaCode", required = false) String devAreaCode,
			@RequestParam(defaultValue = "", value = "isDelayData", required = false) String isDelayData,
			@RequestParam(defaultValue = "", value = "isHightPackage", required = false) String isHightPackage,
			@RequestParam(defaultValue = "", value = "isHightResponse", required = false) String isHightResponse,
			@RequestParam(defaultValue = "", value = "isHaveData", required = false) String isHaveData,
			@RequestParam(defaultValue = "", value = "devFactory", required = false) String devFactory,
			@RequestParam(defaultValue = "", value = "searchFlag", required = false) String searchFlag,
			@RequestParam(defaultValue = "", value = "beginLastPassTime", required = false) String beginLastPassTime,
			@RequestParam(defaultValue = "", value = "endLastPassTime", required = false) String endLastPassTime,
			@RequestParam(defaultValue = "", value = "isPhotoSuccess", required = false) String isPhotoSuccess,
			@RequestParam(defaultValue = "", value = "repStatusCode", required = false) String repStatusCode,
			@RequestParam(defaultValue = "", value = "project", required = false) String project,
			@RequestParam(defaultValue = "", value = "company", required = false) String company,
			@RequestParam(defaultValue = "", value = "picStatusFlag", required = false) String picStatusFlag,Page page,
			HttpServletRequest request) {
		HashMap returnmap = new HashMap();
		List<String> noStatusCodeList = new ArrayList<String>();
		try {
			@SuppressWarnings("unchecked")
			Page checkDeviceInfoPage = (Page) checkDeviceInfoConsumeService.getCheckDeviceInfoPage(DevId, devTypeCode,
					devName, ledType, devStatusCode, isPingConnect, checkResultCode, devAreaCode, isDelayData,
					isHightPackage, isHightResponse, isHaveData, devFactory, searchFlag, beginLastPassTime,
					endLastPassTime, isPhotoSuccess, repStatusCode,project,company,picStatusFlag,page).getResultList();
			List<CheckDeviceInfoDto> listObject = JSONObject
					.parseArray(JSONObject.toJSONString(checkDeviceInfoPage.getResult()), CheckDeviceInfoDto.class);
			// 导出
			List<CheckDeviceInfoDto> listCheckDeviceInfoDto = new ArrayList<>();
			for (int i = 0; i < listObject.size(); i++) {// 网络连接状态赋值；
				if (listObject.get(i).getIsPingConnect() && listObject.get(i).getIsPingConnect() != null) {
					listObject.get(i).setDevBrand("正常");
				} else if (!listObject.get(i).getIsPingConnect() && listObject.get(i).getIsPingConnect() != null) {
					listObject.get(i).setDevBrand("异常");
				} else {
					listObject.get(i).setDevBrand("-");
				}
				// 图片访问；
				if (listObject.get(i).getIsPhotoSuccess() && listObject.get(i).getIsPhotoSuccess() != null) {
					listObject.get(i).setDevFactory("正常");
				} else if (!listObject.get(i).getIsPhotoSuccess()
						&& listObject.get(i).getIsPhotoSuccess() != null) {
					listObject.get(i).setDevFactory("异常");
				} else {
					listObject.get(i).setDevFactory("-");
				}
				//数据延迟；
				if (listObject.get(i).getIsDelayData() && listObject.get(i).getIsDelayData() != null) {
					listObject.get(i).setRepStatusName("延迟");
				} else if (!listObject.get(i).getIsDelayData()
						&& listObject.get(i).getIsDelayData() != null) {
					listObject.get(i).setRepStatusName("非延迟");
				} else {
					listObject.get(i).setRepStatusName("-");
				}
				//实时数据；
				if (listObject.get(i).getIsHaveData() && listObject.get(i).getIsHaveData() != null) {
					listObject.get(i).setRepStatusCode("有");
				} else if (!listObject.get(i).getIsHaveData() && listObject.get(i).getIsHaveData() != null) {
					listObject.get(i).setRepStatusCode("无");
				} else {
					listObject.get(i).setRepStatusCode("-");
				}
				//是否为当前节目；
				if (listObject.get(i).getIsLedProgram() && listObject.get(i).getIsLedProgram() != null) {
					listObject.get(i).setDevBuildPosition("是");
				} else if (!listObject.get(i).getIsLedProgram() && listObject.get(i).getIsLedProgram() != null) {
					listObject.get(i).setDevBuildPosition("否");
				} else {
					listObject.get(i).setDevBuildPosition("-");
				}
				listCheckDeviceInfoDto.add(listObject.get(i));
			}
			CustomHSSFCell[] headers = null;//
			ExcelExportTools et = new ExcelExportTools();
			if ("REPDEVTYPE01".equals(devTypeCode)) {// 信号机；
				headers = new CustomHSSFCell[3];
				headers[0] = new CustomHSSFCell("设备名称", 0, 0, 30, "devTypeName");
				headers[1] = new CustomHSSFCell("网络连接", 1, 0, 30, "devBrand");
				headers[2] = new CustomHSSFCell("巡检结果", 2, 0, 30, "checkResultName");
			} else if ("REPDEVTYPE02".equals(devTypeCode)) {// 视频；
				headers = new CustomHSSFCell[4];
				headers[0] = new CustomHSSFCell("设备名称", 0, 0, 30, "devName");
				headers[1] = new CustomHSSFCell("网络连接", 1, 0, 30, "devBrand");
				headers[2] = new CustomHSSFCell("有无图像", 2, 0, 30, "devFactory");
				headers[3] = new CustomHSSFCell("巡检结果", 3, 0, 30, "checkResultName");
			} else if ("REPDEVTYPE03".equals(devTypeCode)||"REPDEVTYPE04".equals(devTypeCode)) {// 卡口；
				headers = new CustomHSSFCell[7];
				headers[0] = new CustomHSSFCell("名称", 0, 0, 30, "devName");
				headers[1] = new CustomHSSFCell("网络连接", 1, 0, 30, "devBrand");
				headers[2] = new CustomHSSFCell("实时数据", 2, 0, 30, "repStatusCode");
				headers[3] = new CustomHSSFCell("最近上传时间", 3, 0, 30, "lastPassTime");
				headers[4] = new CustomHSSFCell("数据延迟", 4, 0, 30, "repStatusName");
				headers[5] = new CustomHSSFCell("图片访问", 5, 0, 30, "devFactory");
				headers[6] = new CustomHSSFCell("巡检结果", 6, 0, 30, "checkResultName");
			} else if ("REPDEVTYPE05".equals(devTypeCode)) {// 地磁；微波；线圈；
				headers = new CustomHSSFCell[7];
				headers[0] = new CustomHSSFCell("名称", 0, 0, 30, "devName");
				headers[1] = new CustomHSSFCell("设备类型", 1, 0, 30, "devTypeName");
				headers[2] = new CustomHSSFCell("网络连接", 2, 0, 30, "devBrand");
				headers[3] = new CustomHSSFCell("实时数据", 3, 0, 30, "repStatusCode");
				headers[4] = new CustomHSSFCell("最近上传时间", 4, 0, 30, "lastPassTime");
				headers[5] = new CustomHSSFCell("数据延迟", 5, 0, 30, "repStatusName");
				headers[6] = new CustomHSSFCell("巡检结果", 6, 0, 30, "checkResultName");
			} else if ("REPDEVTYPE08".equals(devTypeCode)) {// 诱导；
				headers = new CustomHSSFCell[5];
				headers[0] = new CustomHSSFCell("名称", 0, 0, 30, "devName");
				headers[1] = new CustomHSSFCell("屏类型", 1, 0, 30, "ledTypeName");
				headers[2] = new CustomHSSFCell("网络连接", 2, 0, 30, "devBrand");
				headers[3] = new CustomHSSFCell("当前节目", 3, 0, 30, "devBuildPosition");
				headers[4] = new CustomHSSFCell("巡检结果", 4, 0, 30, "checkResultName");
			}

			String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
			String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
			String rootPath = RestRoot;
			File file = new File(secondDir);
			if (!file.exists()) {// 如果文件夹不存在
				file.mkdir();// 创建文件夹
			}
			SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
			String fileName = "巡检信息表" + time.format(new Date());
			String filePath = secondDir + File.separator + fileName + ".xls";
			boolean flag = false;
			flag = et.exportExcelOfFieldName(listCheckDeviceInfoDto, headers, filePath, "巡检信息表",
					"yyyy-MM-dd hh:mm:ss");
			if (flag) {
				String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
						+ ".xls";
				returnmap.put("path", exportPath);
				returnmap.put("result", "成功");
			} else
				returnmap.put("result", "fail");

		} catch (Exception e) {
			returnmap.put("error", e.getMessage());
			returnmap.put("result", "fail");
		}
		return returnmap;
	}
	
	// 运维管理导出
		@GetMapping(value = { "/exportCheckReport" }, produces = { "application/json; charset=UTF-8" })
		@ResponseBody
		@ApiOperation("巡检报表导出")
		@ApiImplicitParams({ 
			@ApiImplicitParam(name = "devTypeCode", value = "设备类型编号", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String"),
			@ApiImplicitParam(name = "searchFlag", value = "查询标识（DEVICE：设备维度；PERSON：人员维度）", paramType = "query", dataType = "String")
			})
		public Map<String, Object> exportCheckReport(
				@RequestParam(defaultValue = "", value = "devTypeCode", required = false) String devTypeCode,
				@RequestParam(defaultValue = "", value = "startTime", required = false) String startTime,
				@RequestParam(defaultValue = "", value = "endTime", required = false) String endTime,
				@RequestParam(defaultValue = "", value = "searchFlag", required = false) String searchFlag,
				Page page, HttpServletRequest request) {
			HashMap returnmap = new HashMap();
			try {
				@SuppressWarnings("unchecked")
				Page checkReportPage = (Page) iCheckReportConsumService.getCheckReport(devTypeCode, startTime, endTime, page, searchFlag).getResultList();
				List<Map> listObject = checkReportPage.getResult();
				// 导出
				CustomHSSFCell[] headers = null;
				if(searchFlag.equals("DEVICE")){
					headers = new CustomHSSFCell[9];
					headers[0] = new CustomHSSFCell("设备名称", 0, 0, 30, "DEV_TYPE_NAME");
					headers[1] = new CustomHSSFCell("设备数量", 0, 0, 30, "DEVSUM");
					headers[2] = new CustomHSSFCell("巡检次数", 0, 0, 30, "XJZS");
					headers[3] = new CustomHSSFCell("巡检正常", 0, 0, 30, "ZC");
					headers[4] = new CustomHSSFCell("巡检正常率", 0, 0, 30, "ZCL");
					headers[5] = new CustomHSSFCell("巡检异常率", 0, 0, 30, "YCL");
					headers[6] = new CustomHSSFCell("巡检异常数", 0, 0, 30, "YC");
					headers[7] = new CustomHSSFCell("巡检报修数", 0, 0, 30, "XJBX");
					headers[8] = new CustomHSSFCell("巡检报修率", 0, 0, 30, "XJBXL");
				}else if(searchFlag.equals("PERSON")){
					headers = new CustomHSSFCell[8];
					headers[0] = new CustomHSSFCell("姓名", 0, 0, 30, "CHECK_PERSON_NAME");
					headers[2] = new CustomHSSFCell("巡检次数", 0, 0, 30, "XJZS");
					headers[3] = new CustomHSSFCell("巡检正常", 0, 0, 30, "ZC");
					headers[4] = new CustomHSSFCell("巡检正常率", 0, 0, 30, "ZCL");
					headers[5] = new CustomHSSFCell("巡检异常率", 0, 0, 30, "YCL");
					headers[6] = new CustomHSSFCell("巡检异常数", 0, 0, 30, "YC");
					headers[7] = new CustomHSSFCell("巡检报修数", 0, 0, 30, "XJBX");
					headers[0] = new CustomHSSFCell("巡检报修率", 0, 0, 30, "XJBXL");
				}
				ExcelExportTools et = new ExcelExportTools();
				String second = TimeHelper.dateToString(new Date(), "yyyyMMdd");
				String secondDir = FileRoot + File.separator + second;// 在文件上传的文件夹中生成时间戳形式的子文件夹
				String rootPath = RestRoot;
				File file = new File(secondDir);
				if (!file.exists()) {// 如果文件夹不存在
					file.mkdir();// 创建文件夹
				}
				SimpleDateFormat time = new SimpleDateFormat("yyyyMMddHHmmssSS");
				String fileName = "巡检报表" + time.format(new Date());
				String filePath = secondDir + File.separator + fileName + ".xls";
				boolean flag = false;
				flag = et.exportExcelOfFieldName(listObject, headers, filePath, "巡检报表",
						"yyyy-MM-dd hh:mm:ss");
				if (flag) {
					String exportPath = RestRoot + "/file/downloadFile?secondDir=" + second + "&fileName=" + fileName
							+ ".xls";
					returnmap.put("path", exportPath);
					returnmap.put("result", "成功");
				} else
					returnmap.put("result", "fail");

			} catch (Exception e) {
				returnmap.put("error", e.getMessage());
				returnmap.put("result", "fail");
			}
			return returnmap;
		}

}
